package com.neuedu.his5.mvc;

// HomeController.java


import com.neuedu.his5.entity.testUser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/tl") // Thymeleaf 模块的请求前缀
public class HomeController {

    @GetMapping("/test")
    public String home(Model model) {
        // 填充单个对象
        testUser user = new testUser("Alice", 25);
        model.addAttribute("user", user);

        // 填充列表数据
        List<String> hobbies = Arrays.asList("阅读", "编程", "旅行");
        model.addAttribute("hobbies", hobbies);

        // 填充布尔值（用于条件判断）
        model.addAttribute("isStudent", true);

        return "index"; // 对应 templates/index.html
    }
}